package com.hefei.hight.reflection;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author caizhengjun
 * @date 2020/9/5 1:49 下午
 */
public class Test10 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("com.hefei.hight.reflection.Student");
        Constructor<?>[] constructors = aClass.getConstructors();
        for (Constructor<?> constructor : constructors) {
            System.out.println(constructor);
        }

        Constructor<?> constructor = aClass.getConstructor(String.class, Integer.class);
        Object o = constructor.newInstance("张三", 25);
        Method toString = aClass.getDeclaredMethod("toString");
        toString.invoke(o);
    }
}
